package com.zjcode.cdcer.controller;

import com.chinatechstar.component.commons.result.ListResult;
import com.chinatechstar.component.commons.result.ResultBuilder;
import com.chinatechstar.component.commons.supports.PageData;
import com.zjcode.cdcer.model.basic.JsonObj;
import com.zjcode.cdcer.service.AnnualReportSummaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ZQM
 * @date 2023/10/12 15:36
 */
@RestController
@RequestMapping("/v1/annualReportSummary")
public class AnnualReportSummaryController {

    @Autowired
    private AnnualReportSummaryService annualReportSummaryService;

    /**
     * 年报总结添加
     */
    @PostMapping("/add")
    public JsonObj add(@RequestBody PageData pageData) {
        return annualReportSummaryService.add(pageData);
    }

    /**
     * 年报总结查看（单个）
     */
    @GetMapping("/selById")
    public JsonObj selById(@RequestParam String id) {
        return annualReportSummaryService.selById(id);
    }

    /**
     * 年报总结查看（列表）
     */
    @PostMapping("/selList")
    public ListResult<Object> selList(@RequestBody PageData pageData) {
        return ResultBuilder.buildListSuccess(annualReportSummaryService.selList(pageData));
    }

    /**
     * 年报总结删除
     */
    @GetMapping("/del")
    public JsonObj del(@RequestParam String id) {
        return annualReportSummaryService.del(id);
    }

    /**
     * 展示界面（根据当前登录用户所属机构）
     */
    @GetMapping("/showAllFile")
    public ListResult<Object> showAllFile(@RequestParam Long userId, @RequestParam Integer type, @RequestParam(required = false) String screeningYear) {
        return ResultBuilder.buildListSuccess(annualReportSummaryService.showAllFile(userId,type,screeningYear));
    }
}
